package com.example.human_resource_management.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.human_resource_management.entry.dto.EmployeeDto;
import com.example.human_resource_management.entry.dto.PageDto;
import com.example.human_resource_management.entry.dto.PagesDto;
import com.example.human_resource_management.entry.po.Employee;
import com.example.human_resource_management.service.EmployeeService;
import com.example.human_resource_management.mapper.EmployeeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Lenovo
* @description 针对表【employee(员工表)】的数据库操作Service实现
* @createDate 2025-06-09 08:48:41
*/
@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee>
    implements EmployeeService{
    @Autowired
    private EmployeeMapper employeeMapper;


    @Override
    public Employee getEmployeeById(Long empId) {
        return employeeMapper.selectById(empId);
    }

    @Override
    public EmployeeDto getEmployeeDetails(Long empId) {
        return employeeMapper.selectEmployeeDetails(empId);
    }


    @Override
    public boolean updateEmployeeFields(Long empId, String name, String gender, String contact) {
        Employee employee = new Employee();
        employee.setEmpId(empId);
        employee.setName(name);
        employee.setGender(gender);
        employee.setContact(contact);
        return updateById(employee);
    }

    @Override
    public PageDto get(Long empId) {
        return employeeMapper.getEmployeeInfo(empId);
    }

    @Override
    public PagesDto getpage(Long empId) {
        return employeeMapper.getpages(empId);
    }






    //管理员端
@Override
public List<EmployeeDto> selectAllEmployeeDetails() {
    return employeeMapper.selectAllEmployeeDetails();
}

    @Override
    public boolean insertEmployee(Employee employee) {
        int result = employeeMapper.insertEmployee(employee);
        return result > 0;
    }

    @Override
    public boolean updateEmployee(Employee employee) {
        int result = employeeMapper.updateEmployee(employee);
        return result > 0;
    }

    @Override
    public boolean deleteEmployee(Long empId) {
        int result = employeeMapper.deleteEmployee(empId);
        return result > 0;
    }


}




